
<template>
<div style="width: 430px;height: 932px;">
  <van-form v-model="pojo">
    <van-field
      v-model="pojo.username"
      name="用户名"
      label="用户名"
      placeholder="用户名"
      :rules="[{ required: true, message: '请填写用户名' }]"
    />
    <van-field
      v-model="pojo.password"
      type="password"
      name="密码"
      label="密码"
      placeholder="密码"
      :rules="[{ required: true, message: '请填写密码' }]"
    />
    <div style="margin: 16px;">
      <van-button round block type="info" native-type="submit" @click="toregister()">提交</van-button>
    </div>
  </van-form>
</div>
</template>

<script>
export default {
  data () {
    return {
      pojo: {
        username: '',
        password: '',
      },
    }
  },
  methods: {
    toregister(){
      if(this.pojo.username!=null&&this.pojo.password!=null){
        this.$axios.post('/admin/register',this.pojo).then(res=>{
          if(res.data.code==200){
            this.$toast.success('注册成功')
            this.$router.push('/')
          }else{
            this.$toast.fail('该昵称已经被使用')
          }
        })
      }else {
        this.$toast.fail('请输入完整信息')
      }

    }
  },
  created() {
  }
}
</script>

<style scoped>

</style>
